//
//  ThirtysixViewController.m
//  Depressed.domo
//
//  Created by rimi on 16/5/27.
//  Copyright © 2016年 薛涛. All rights reserved.
//

#import "ThirtysixViewController.h"
#import "UIView+BQChangeFrameValue.h"
#import "BQlinennFlowLayout.h"
#import "BBQCollectionViewCell.h"

static NSString *const KBQCollectionViewCell = @"BBQCollectionViewCell";
@interface ThirtysixViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (nonatomic, strong)UICollectionView *collection;
@property (nonatomic, strong)NSMutableArray *array;
@end

@implementation ThirtysixViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"画框";
    [self initUI];
    [self initData];
}

- (void)initData {
    _array = [NSMutableArray array];
    for (int i = 1; i<= 20; i ++) {
        [_array addObject:[NSString stringWithFormat:@"%d",i]];
    }
}

- (void)initUI {
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.collection];
}

#pragma mark - UICollectionViewDataSource Method
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _array.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    BBQCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KBQCollectionViewCell forIndexPath:indexPath];
    cell.imageName = _array[indexPath.item];
    return cell;
}

#pragma mark - get
- (UICollectionView *)collection{
    if (_collection == nil) {
        _collection = [[UICollectionView alloc] initWithFrame:CRM(0, 200, self.view.width, 200) collectionViewLayout:[[BQlinennFlowLayout alloc]init]];
        _collection.delegate = self;
        _collection.dataSource = self;
        _collection.backgroundColor = [UIColor purpleColor];
        [_collection registerNib:[UINib nibWithNibName:@"BBQCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:KBQCollectionViewCell];
    }
    return _collection;
}
@end
